<template>
	<view class="container">
		<view class="nav" :style="'padding-top:'+barHeight+'px'">
			<image class="back" @click="back()" src="../../../static/index/back.png" mode=""></image>
			<view class="nav_name">
				积分
			</view>
		</view>

		<view class="card">
			<view class="card_left">
				<view class="card_count">
					{{money}}
				</view>
				<view class="card_name">
					总积分
				</view>
			</view>
			<view class="card_right" @click="goto('pagesA/index/recharge')">
				充值
			</view>
		</view>

		<scroll-view scroll-y="true" class="scroll-box" @scrolltolower="lower()">
			<u-empty v-if="list.length == 0" mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png">
			</u-empty>
			<view class="list" v-for="item in list">
				<view class="list_left">
					{{item.memo}}
				</view>
				<view class="list_right">
					<view class="list_price">
						{{item.credit1}}
					</view>
					<view class="list_time">
						{{item.createtime | date('yyyy-mm-dd hh:MM')}}
					</view>
				</view>
			</view>
		</scroll-view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				barHeight: 0,
				page: 1,
				finish: false,
				money: '',
				list: []
			}
		},
		onLoad() {
			this.barHeight = uni.getSystemInfoSync().statusBarHeight;
			this.getinfo()
		},
		methods: {
			lower() {
				this.page++ 
				this.getinfo()
			},
			getinfo() {
				if (this.finish) {
					return
				}
				
				uni.$u.http.post('/rechargecredit', {
					page: this.page,
					type: 'list'
				}).then(res => {
					if (res.code == 1) {
						this.money = res.data.money
						console.log(res.data)
						this.list = this.list.concat(res.data.list)
						if (res.data.list.length === 0) {
							this.finish = true
						}
					}
				}).catch((res) => {

				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		background-color: #fff;
		display: flex;
		flex-direction: column;

		.nav {
			margin: 0 30rpx;
			padding-bottom: 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;

			.back {
				width: 40rpx;
				height: 40rpx;
			}

			.nav_name {
				flex: 1;
				margin-right: 30rpx;
				text-align: center;
				font-size: 36rpx;
				font-weight: bold;
				line-height: 40rpx;
			}
		}

		.card {
			margin: auto;
			margin-top: 60rpx;
			width: 686rpx;
			height: 206rpx;
			background: #FEBF4E;
			border-radius: 24rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;

			.card_left {
				margin-left: 40rpx;
				display: flex;
				flex-direction: column;
				align-items: center;

				.card_count {
					margin-bottom: 20rpx;
					font-size: 50rpx;
					font-weight: bold;
					line-height: 40rpx;
				}
			}

			.card_right {
				margin-right: 40rpx;
				width: 132rpx;
				height: 56rpx;
				background: #FAFAFA;
				border-radius: 28rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 28rpx;
				line-height: 40rpx;
			}
		}

		.scroll-box {
			margin-top: 30rpx;
			flex: 1;
			overflow: hidden;

			.list {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				margin: 15rpx 30rpx;
				padding: 50rpx 30rpx;
				border-radius: 20rpx;
				background-color: #F9FAFB;

				.list_left {
					font-size: 28rpx;
					color: #323232;
					line-height: 38rpx;
				}

				.list_right {
					display: flex;
					align-items: flex-end;
					flex-direction: column;

					.list_price {
						margin-bottom: 10rpx;
						font-size: 32rpx;
						font-weight: bold;
						color: #E90000;
						line-height: 38rpx;
					}

					.list_time {
						font-size: 28rpx;
						color: #989898;
						line-height: 34rpx;
					}
				}
			}
		}
	}
</style>
